#include <iostream>
#include <QDebug>
#include <QtXlsx/QtXlsx>
#include "exportxlsx.h"
using namespace std;

exportxlsx::exportxlsx()
{

}
int exportxlsx::create(){
        QXlsx::Document xlsx;
        xlsx.write("A1", "Hello Qt!");
        xlsx.saveAs("Test.xlsx");

    qDebug()<<"begin create";
    if(doc.LoadFile("Database/DataRetest/30_1_CL2030 Test Plan.xml")){
        qDebug()<<"file load error";
        doc.PrintError();
        return 1;
    }
    root=doc.RootElement();
    QString deviceNo(root->Attribute("DeviceID"));
    tinyxml2::XMLElement *firstItems = root->FirstChildElement("Items");
    tinyxml2::XMLElement *firstGroupOfItems = firstItems->FirstChildElement("GroupData");
    tinyxml2::XMLElement *firstItemsOfGroup = firstGroupOfItems->FirstChildElement("Items");
    tinyxml2::XMLElement *itemData=firstItemsOfGroup->FirstChildElement();
    QString current("5A");
    QString refvalue;
    while (itemData) {
        current=QString(itemData->Attribute("Parameter")).split("_")[3];
        qDebug()<<current;
        refvalue=itemData->Attribute("ReferenceValue");
        qDebug()<<refvalue;
        qDebug()<<itemData->Attribute("MeasuredValue");
        qDebug()<<(itemData->Attribute("ErrorValue"));
        qDebug()<<itemData->Attribute("ReferenceValue2");
        qDebug()<<itemData->Attribute("MeasuredValue2");
        qDebug()<<itemData->Attribute("ErrorValue2");
        itemData=itemData->NextSiblingElement();
    }
    cout<<"end create"<<endl;
    return 0;
}

